<?php
class TDataTableCandidatoHistorico extends TDataTable
{
    public function __construct($usuario, $pfcid, $options)
    {
        $model  = new ViewHistoricoSgc();
              
		$criterio = array();
		$criterio['orderBy'] = 'data';
		$criterio['order'] = 'desc';
		
		if ($pfcid == PerfilComportamental::Orgao)
			$criterio['precondicao'] = 'contratoid in (SELECT contratoid FROM contratos WHERE orgaoid ='.$usuario->orgaoid.'))';
    					
		if ($pfcid == PerfilComportamental::NucleoGestor)
    		$criterio['precondicao'] = 'nucleogestorid ='.$usuario->nucleogestorid;
    
   		if ($pfcid == PerfilComportamental::Empresa)
   			$criterio['precondicao'] = 'contratoid in (SELECT contratoid FROM contratos WHERE empresaid ='.$usuario->empresaid;
		
		$key = 'candidatoid';
				        
		parent::__construct($model, $key, $criterio, $options);  
		$this->addColumnsData(array(
		                        array('name'=>'cpf', 'header'=>'cpf','mask'=>TDataTableColumn::MASK_CPF), 
		                        'nome',
		                        'vagaid',
								'orgao',
		                        'empresa',
		                        array('name'=> 'contratoid', 'header'=>'CONTID'),
		                        array('name'=> 'numeroorgao','header'=>'nr cont'),
		                        array('name'=> 'numeroaditivo','header'=>'nr adit'), 
								array('name'=> 'statuscontrato','header'=>'status contrato'), 								
		                        'lotacao',
								array('name'=>'nucleogestor','header'=>'nucleo gestor'),		                        
		                        'cargo',
		                        array('name'=>'admissao', 'header'=>'vinculacao'), 
		                        array('name'=> 'demissao','header' =>'desvinculacao'), 
		                        'statuscandidato',		                        
		                        array('name'=> 'data','header' =>'dt. registro')
		                         ));  
		$this->addFiltersCombo(array('orgao', 'empresa','statuscontrato','lotacao','nucleogestor', 'cargo','statuscandidato'));    
    }
}